import { request } from '../request';

/* 删除文章 */
export function articleOperateDel(params: { id: string }) {
  return request<boolean>({
    url: '/article-operate/del',
    method: 'post',
    data: params,
  });
}

/* 编辑文章参数加载 */
export function articleOperateEditData(params: { id: string }) {
  return request<
    {
      content: string;
      categoryId: string;
      topic: Api.SelectVO;
      /*标签 */
      tagList: Api.SelectVO[];
    } & Api.Article
  >({
    url: '/article-operate/edit-data',
    method: 'post',
    data: params,
  });
}

/* 添加页面参数加载 */
export function articleOperateInit() {
  return request<{
    categoryList: Array<Api.SelectVO>;
    tagList: Array<Api.SelectVO>;
    topicList: Array<Api.SelectVO>;
  }>({
    url: '/article-operate/init',
    method: 'get',
  });
}

/* 发布文章 */
export function articleOperatePush(params: {
  /*主键 */
  id?: string;
  /*摘要 */
  summary: string;
  /*标题 */
  title: string;
  /*封面 */
  articleCover?: string;
  /*文章内容 */
  content: string;
  htmlContent: string;
  /*分类ID */
  categoryId: string;
  /*标签 */
  tagList: Api.SelectVO[];
  /* 话题Id */
  topic: Api.SelectVO;
  /* 文章状态 */
  status: number;
}) {
  return request<string>({
    url: '/article-operate/push',
    method: 'post',
    data: params,
  });
}

/* 编辑文章 */
export function articleOperateEdit(params: {
  /*主键 */
  id: string;
  /*摘要 */
  summary: string;
  /*标题 */
  title: string;
  /*封面 */
  articleCover?: string;
  /*文章内容 */
  content: string;
  /*分类ID */
  categoryId: string;
  /*标签 */
  tagList: Api.SelectVO[];
  /* 话题Id */
  topic: Api.SelectVO;
}) {
  return request<string>({
    url: '/article-operate/edit',
    method: 'post',
    data: params,
  });
}

/* 保存至草稿 */
export function articleOperateToDraft(params: {
  /*主键 */
  id?: string;
  /*摘要 */
  summary: string;
  /*标题 */
  title: string;
  /*封面 */
  articleCover?: string;
  /*文章内容 */
  content: string;

  /*分类ID */
  categoryId: string;

  /*标签 */
  tagList?: Api.SelectVO[];
}) {
  return request<string>({
    url: '/article-operate/to-draft',
    method: 'post',
    data: params,
  });
}
